package org.atovio.quickweb.controller;

import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author AtoVio, Winter Yuan
 */
@RestController
public class PathController {

    // 使用 ？ 匹配单个字符
    @GetMapping("/file/t?st.html")
    public String path1(HttpServletRequest request) {
        return "path请求为： " + request.getRequestURI();
    }

    // 路径变量 {*变量名称}。注意，路径变量不是请求中的参数？
    @GetMapping("/order/{*path}")
    public String path2(HttpServletRequest request, @PathVariable("path") String orderPath) {
        return "path请求为： " + request.getRequestURI() + ", id=" + orderPath;
    }
}
